package 流程控制.循环结构;

public class for学习 {

    public static void main(String[] args) {
        int osh = 0;
        int jsh = 0;

        for_返回类 os = os(12);
        int[] os1 = os.getOs();
        int[] js1 = os.getJs();




        //偶数
        System.out.println("偶数：");
        for (int i = 0; i < os1.length; i++) {
            osh = osh + os1[i];
            System.out.print(os1[i] + " ");
        }
        //奇数
        System.out.println("\n" + "奇数：");
        for (int i = 0; i < js1.length; i++) {
            jsh = jsh + js1[i];
            System.out.print(js1[i] + " ");
        }
        System.out.println("\n" + "偶数之和：" + osh);
        System.out.println("奇数之和：" + jsh);
        System.out.println("奇偶之和" + (osh+jsh));

        cs(100,1);

    }

    /**
     *输入一个数返回该数的所有奇数,所有偶数
     * @param a
     * @return
     */
    public static for_返回类 os(int a) {
        int j1;
        int o1;
        if (jo(a)){
             j1 = a / 2 + 1;
             o1 = j1 - 1;
        }else {
            j1 = a/2;
            o1 = j1;
        }
        int[] os = new int[o1];
        int[] js = new int[j1];
        for_返回类 es = new for_返回类();
        for (int i = 1, j = 0, o = 0; i <= a; i++) {
            if (i % 2 == 0) {
                os[o] = i;
                o++;
//                System.out.println("偶数：" + i);
            } else {
                js[j] = i;
                j++;
//                System.out.println("奇数：" + i);
            }
        }
        es.setJs(js);
        es.setOs(os);
        return es;
    }

    /**
     * 一个数判断奇偶,偶数返回false ,奇数返回true
     * @param a
     * @return
     */
    public static boolean jo(int a) {
        boolean b = true;
        if (a % 2 == 0) {
            b = false;
        }
        return b;
    }

    /**
     * 输出范围为0-cs中所有能整除bcs的所有数,且每行只输出3个数
     * @param cs
     * @param bcs
     */
    public static void cs(int cs, int bcs){
        for (int i = 1,j = 1;i <= cs;i++){
            if (i % bcs == 0){

                System.out.print(i + "  ");

                if (j%3 == 0) {
                    System.out.println();
                }
                j++;


            }
        }
    }



}
